//package com.allwees.bs.c.module.product.util;
//
//import com.allwees.bs.c.module.product.dto.ProductDetailsDTO;
//import com.allwees.bs.core.model.useraction.bo.ProductShowLogDTO;
//import com.allwees.bs.core.model.useraction.bo.model.ProductShow;
//import com.allwees.bs.core.model.useraction.constant.EProductShowType;
//import com.allwees.bs.core.modelbase.page.PaginateDTO;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.collections4.CollectionUtils;
//
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * 记录Product展示
// *
// * @author yangylsky
// * @since 2020-03-30
// *
// */
//@Slf4j
//public class ProductShowLogUtil {
//	public static void logProductShow(EProductShowType uaType, String key, PaginateDTO<ProductDetailsDTO> page) {
//		try {
//			ProductShowLogDTO showLog = new ProductShowLogDTO().setUaType(uaType);
//	        ProductShowLogUtil._updateShowItems(showLog, page);
//			showLog.setKey(key)
//	        		.setCurrent((int) page.getCurrent())
//	        		.setPageSize(page.getSize())
//	        		.setTotal((int) page.getTotal())
//	        		.setCount(page.getCount())
//					.updateRequestInfo()
//					.sendToMq();
//		} catch(Exception e) {
//			log.error("logAction logProductShow failed", e);
//		}
//	}
//
//	private static void _updateShowItems(ProductShowLogDTO showLog, PaginateDTO<ProductDetailsDTO> page) {
//    	List<ProductDetailsDTO> products = page.getResults();
//    	if(CollectionUtils.isNotEmpty(products)) {
//        	List<ProductShow> showItems = new ArrayList<>(products.size());
//        	for(int i = 0; i < products.size(); i++) {
//        		ProductDetailsDTO product = products.get(i);
//        		Integer pos = (int) (page.getSize() * (page.getCurrent() - 1) + i  + 1);
//        		showItems.add(new ProductShow(product.getUuid(), product.getRetailerUuid(), product.getStoreUuid(), pos));
//        	}
//        	showLog.setShowItems(showItems);
//    	}
//    }
//
//	public static void logProductShow(EProductShowType uaType, String key, List<ProductDetailsDTO> products) {
//		try {
//			ProductShowLogDTO showLog = new ProductShowLogDTO().setUaType(uaType);
//	        ProductShowLogUtil._updateShowItems(showLog, products);
//			showLog.setKey(key)
//	        		.setCurrent(1)
//	        		.setPageSize(products.size())
//	        		.setTotal(products.size())
//	        		.setCount(products.size())
//					.updateRequestInfo()
//					.sendToMq();
//		} catch(Exception e) {
//			log.error("logAction logProductShow failed", e);
//		}
//	}
//
//    private static void _updateShowItems(ProductShowLogDTO showLog, List<ProductDetailsDTO> products) {
//    	if(CollectionUtils.isNotEmpty(products)) {
//        	List<ProductShow> showItems = new ArrayList<>(products.size());
//        	for(int i = 0; i < products.size(); i++) {
//        		ProductDetailsDTO product = products.get(i);
//        		showItems.add(new ProductShow(product.getUuid(), product.getRetailerUuid(), product.getStoreUuid(), i + 1));
//        	}
//        	showLog.setShowItems(showItems);
//    	}
//    }
//}
